package com.lhl.express.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.lhl.express.R;
import com.lhl.express.bean.Express;

import java.util.List;

public class ExpressAdapter extends ArrayAdapter<Express> {
    int resourceid;
    public ExpressAdapter(@NonNull Context context, int resource, @NonNull List<Express> objects) {
        super(context, resource, objects);
        this.resourceid=resource;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent){
        View view=convertView;
        if (view==null){
            view= LayoutInflater.from(getContext()).inflate(resourceid,null);

        }
        ImageView iv_pic = view.findViewById(R.id.iv_pic);
        TextView tv1 = view.findViewById(R.id.tv1);
        TextView tv2 = view.findViewById(R.id.tv2);
        Express b=getItem(position);
        iv_pic.setImageResource(b.getImg());
        tv1.setText(b.getName());
        tv2.setText(b.getTitle());
        return view;
    }
}
